//
//  CRHeader.h
//  TestPrj
//
//  Created by 朱铅峰 on 2020/8/3.
//  Copyright © 2020 Xing. All rights reserved.
//

#ifndef CRHeader_h
#define CRHeader_h

#import <UIKit/UIKit.h>

//输入状态
typedef enum : NSUInteger {
    CRInputStatusText, //文字
    CRInputStatusAudio, //语音
    CRInputStatusEmotion, //表情
    CRInputStatusMore //更多
} CRInputStatus;

//输入栏子视图类型
typedef enum : NSUInteger {
    CRInputBarItemTypeVoice, //录音文本切换按钮
    CRInputBarItemTypeTextAndRecord, //文本输入框或录音按钮
    CRInputBarItemTypeEmoticon, //表情贴图
    CRInputBarItemTypeMore //更多菜单
} CRInputBarItemType;

//录音状态
typedef enum : NSUInteger {
    CRAudioRecordPhaseStart, //开始
    CRAudioRecordPhaseRecording, //录音中
    CRAudioRecordPhaseCancelling, //取消中
    CRAudioRecordPhaseEnd //结束
} CRAudioRecordPhase;





//会话类型
typedef enum : NSUInteger {
    CRSessionTypeP2P = 0, //点对点，单人聊天
    CRSessionTypeTeam = 1 //群组
} CRSessionType;

//消息发送状态
typedef enum : NSUInteger {
    CRMessageDeliveryStateFailed,//发送失败
    CRMessageDeliveryStateDelivering,//发送中
    CRMessageDeliveryStateDeliverd //发送成功
} CRMessageDeliveryState;


//消息内容类型
typedef enum : NSUInteger {
     /**
        *  文本类型消息
        */
       CRMessageTypeText          = 0,
       /**
        *  图片类型消息
        */
       CRMessageTypeImage         = 1,
       /**
        *  声音类型消息
        */
       CRMessageTypeAudio         = 2,
       /**
        *  视频类型消息
        */
       CRMessageTypeVideo         = 3,
       /**
        *  位置类型消息
        */
       CRMessageTypeLocation      = 4,
       /**
        *  通知类型消息
        */
       CRMessageTypeNotification  = 5,
       /**
        *  文件类型消息
        */
       CRMessageTypeFile          = 6,
       /**
        *  提醒类型消息
        */
       CRMessageTypeTip           = 10,
       /**
        *  机器人类型消息
        */
       CRMessageTypeRobot         = 11,
       /**
        *  自定义类型消息
        */
       CRMessageTypeCustom        = 100
} CRMessageType;

//头像类型
typedef enum : NSUInteger {
    /*矩形直角头像*/
    CRKitAvatarTypeNone,
    /*圆形头像*/
    CRKitAvatarTypeRounded,
    /*圆角头像*/
    CRKitAvatarTypeRadiusCorner
} CRKitAvatarType;



//键盘通知
static NSString *CRKeyboardWillChangeFrameNotification = @"CRKeyboardWillChangeFrameNotification";
static NSString *CRKeyboardWillHideNotification = @"CRKeyboardWillHideNotification";

/**
 *  用户资料场景（头像等）
 */
static NSString *const CRNOSSceneTypeAvatar = @"1222";

/**
 *  IM 消息 （图片，文件，音频，视频消息发送）
 */
static NSString *const CRNOSSceneTypeMessage = @"1333";

/**
*  用户资料场景（下载权限）
*/
static NSString *const CRNOSSceneTypeSecurity = @"1555";


//主线程CGD
#define CRKit_Dispatch_Sync_Main(block)\
if ([NSThread isMainThread]) {\
block();\
} else {\
dispatch_sync(dispatch_get_main_queue(), block);\
}

#define CRKit_Dispatch_Async_Main(block)\
if ([NSThread isMainThread]) {\
block();\
} else {\
dispatch_async(dispatch_get_main_queue(), block);\
}


//颜色
#define CRKit_UIColorFromRGBA(rgbValue, alphaValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0x0000FF))/255.0 \
alpha:alphaValue]

#define CRKit_UIColorFromRGB(rgbValue) CRKit_UIColorFromRGBA(rgbValue, 1.0)


//路径定义
#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) firstObject]
#define kRecordImagePath [NSString stringWithFormat:@"%@/%@",kDocumentPath,@"images"] //图片路径
#define kRecordAudioPath [NSString stringWithFormat:@"%@/%@",kDocumentPath,@"audios"] //录音路径
#define kRecordAudioCacheFilePath [NSString stringWithFormat:@"%@/%@",kDocumentPath,@"tempFile.wav"] //录音缓存文件

#endif /* CRHeader_h */
